package main

import (
	"sync"
	"net/http"
	"fmt"
	"log"
)

var mu sync.Mutex
var count int
func main() {
	http.HandleFunc("/",handler)
	http.HandleFunc("/count",counter)
	log.Fatal(http.ListenAndServe("localhost:8080" ,nil))

}
func handler(w http.ResponseWriter ,r *http.Request){
	mu.Lock()
	count++
	mu.Unlock()
	fmt.Fprintf(w, "URL.Path =%q\n", r.URL.Path)
}
func counter(w http.ResponseWriter ,r *http.Request){
	mu.Lock()
	fmt.Fprint(w,"Count %d\n", count)
	mu.Unlock()
}